FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 5000

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["src/MyLinuxService.Api/MyLinuxService.Api.csproj", "src/MyLinuxService.Api/"]
COPY ["src/MyLinuxService.Core/MyLinuxService.Core.csproj", "src/MyLinuxService.Core/"]
COPY ["src/MyLinuxService.Infrastructure/MyLinuxService.Infrastructure.csproj", "src/MyLinuxService.Infrastructure/"]
RUN dotnet restore "src/MyLinuxService.Api/MyLinuxService.Api.csproj"

COPY . .
WORKDIR "/src/src/MyLinuxService.Api"
RUN dotnet build "MyLinuxService.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyLinuxService.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyLinuxService.Api.dll"]
